package com.carkeeper.storebill.dao;

import com.carkeeper.storebill.pojo.StoreBill;
import com.carkeeper.storebill.pojo.StoreBillShow;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface StoreBillMapper extends Mapper<StoreBill> {


    @Select("select pay_status from tb_store_bill group by pay_status")
    List<String> findPayStatusList();

    @Select("<script>select store_id as storeId,store_name as storeName,SUM(price) as totalPrice from tb_store_bill where pay_status=1" +
            "<if test='#{storeId} != null || #{storeName} != null'>" +
                "<if test='storeId != null'>" +
                "and store_id=#{storeId} " +
                "</if>" +
                "<if test='storeName != null'>" +
                "and store_name=#{storeName}" +
                "</if>" +
            "</if>" +
            " group by store_id,store_name</script>")
    List<StoreBillShow> findShowStoreBill(Map<String,String> searchMap);

    @Select("select * from tb_store_bill where pay_status=0 and store_id=#{storeId}")
    List<StoreBill> findNotPayStoreBillByStoreId(@Param("storeId") Integer storeId);
}
